<template>
  <div class="app-container">
    <el-form @submit.native.prevent :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="90px">
      <!-- 事件选择 -->
      <el-form-item :label="$t('时间选择')" prop="skuNo">
        <el-date-picker value-format="yyyy-MM-dd " clearable v-model="queryParams.createTime" type="date" />
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="getList">
          <!-- 搜索 -->
          {{ $t('搜索') }}
        </el-button>
      </el-form-item>
    </el-form>
    <el-row :gutter="10" class="mb8">
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table :height="calTableHeight()" v-loading="loading" ref="TableRef" :data="conversionRateList">
      <el-table-column label="USD/JPY" align="center" prop="conversionRateUsd" />

      <el-table-column label="CNY/JPY" align="center" prop="conversionRateCny" />

      <el-table-column :label="$t('创建时间')" align="center" prop="createTime" />
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { listConversionRate } from '@/api/basicSetting/conversionRate'

export default {
  activated() {
    this.$nextTick(() => this.$refs['TableRef']?.doLayout())
  },
  name: 'ConversionRate',
  data() {
    return {
      /**遮罩层*/
      loading: true,
      /**显示搜索条件*/
      showSearch: false,
      /**总条数*/
      total: 0,
      /**汇率（每天更新）表格数据*/
      conversionRateList: [],
      /**查询参数*/
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        createTime: '',
      },
    }
  },
  created() {
    this.getList()
  },
  methods: {
    /** 查询汇率（每天更新）列表 */
    getList() {
      this.loading = true
      listConversionRate(this.queryParams).then((response) => {
        this.conversionRateList = response.rows
        this.total = response.total
        this.loading = false
      })
    },
  },
}
</script>
